package com.wfs.util;

import java.util.HashMap;
import java.util.Map;

public class QRCodeGeneratorUtil {

	//Charts API constants
	private static final String CHARTS_API_URL = "https://chart.googleapis.com/chart?";
	private static final String CHARTS_API_SIZE_PARAM = "chs";
	private static final String CHARTS_API_TYPE_PARAM = "cht";
	private static final String CHARTS_API_INPUT_PARAM = "chl";


	/**
	 * Generate 500x500 QR image from text
	 * Uses Google Charts API
	 * @param text	text to be encoded
	 * @return url of generated image
	 */
	public static String generateQRFromText(String text){
		Map<String,String> param = new HashMap<String,String>();
		param.put(CHARTS_API_SIZE_PARAM,"500x500");
		param.put(CHARTS_API_TYPE_PARAM,"qr");
		param.put(CHARTS_API_INPUT_PARAM,text);
		String url_string = CHARTS_API_URL + WebServiceUtil.parseParameters(param);
		return url_string;
	}

}
